package com.punch.user.controller;

import com.punch.common.model.Result;
import com.punch.common.vo.user.school.AppSchoolVO;
import com.punch.user.service.SchoolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @className: SchoolController
 * @description: 学校管理控制层
 * @author: wujj
 * @since: 2020/12/05 15:30
 **/
@RestController
@Api(tags = "用户模块--学校")
public class SchoolController {

    @Resource
    private SchoolService schoolService;


    /**
     * 根据地区id查询学校
     *
     * @param areaId 地区id
     * @return List<AppSchoolVO>
     */
    @GetMapping(value = "/school/area/{areaId}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "根据地区id查询学校", notes = "根据地区id查询学校", produces = "application/json")
    public Result<List<AppSchoolVO>> listSchool(@PathVariable Integer areaId) {
        return Result.succeed(schoolService.listSchool(areaId));
    }


    /**
     * 学校年级下的班级
     *
     * @param schoolId 班级id
     * @param grade    年级
     * @return List<string>
     */
    @GetMapping(value = "/school/{schoolId}/grade/{grade}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "学校年级下的班级", notes = "只有学校addStuType为0时才会请求该接口", produces = "application/json")
    public Result<List<String>> listGradeClass(@PathVariable Long schoolId, @PathVariable Integer grade) {
        return Result.succeed(schoolService.listGradeClass(schoolId, grade));
    }
}
